<template>
	<view>
		<uniList :housingList='housingList' class="content" v-on:getShelData="getShelData"></uniList>
	</view>
</template>

<script>
	import uniList from '@/components/houseList.vue';
	export default {
		components: {
			uniList
		},
		data() {
			return {
				housingList: [], // 房源数据
			}
		},
		onLoad(options) {
			if (options.type == "release") {
				this.$u.api.releaseHous(localStorage.getItem('userId')).then(res => {
					res.data.forEach(ele => {
						ele.characteristic = ele.characteristic ? ele.characteristic.split(",") : [];
					})

					this.housingList = res.data;
				})

			} else {
				this.getShelData();
			}

		},
		methods: {
			getShelData() {
				console.log("kkkk")
				this.$u.api.shelfHous(localStorage.getItem('userId')).then(res => {
					res.data.forEach(ele => {
						ele.characteristic = ele.characteristic ? ele.characteristic.split(",") : [];
					})
					this.housingList = res.data;
				})
			}
		}
	}
</script>

<style scoped>
	.content {
		margin: 24rpx 30rpx;
	}
</style>
